<%--
  Created by IntelliJ IDEA.
  User: 陈帅玺
  Date: 2019-01-04
  Time: 14:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set value="${pageContext.request.contextPath}" var="path"></c:set>
<!DOCTYPE html>
<html>
<head>
    <title>服务处理</title>
    <link rel="stylesheet" href="/assets/css/loader-style.css">
    <link rel="stylesheet" href="/assets/css/bootstrap.css">
    <link rel="stylesheet" href="/layui/css/layui.css">
    <script src="/js/jquery-3.3.1.js"></script>
    <script src="/layui/layui.js"></script>
    <script src="/js/config.js"></script>
    <link rel="shortcut icon" href="/assets/ico/minus.png">
    <style>
        .box-pad {
            padding: 1%
        }
        #handle {
            display: none;
            padding: 30px 50px 0 50px;
        }
        #serviceForm input {
            border: none;
        }
    </style>
</head>
<body>
<div id="handle">
    <form class="layui-form" id="serviceForm" lay-filter="serviceForm">
        <input type="hidden" value="" name="id" id="chuliid">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">客户</label>
                <div class="layui-input-inline">
                    <input type="text" name="clientele" class="layui-input" readonly>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">服务类型：</label>
                <div class="layui-inline">
                    <input type="text" name="" id="detailType" class="layui-input" readonly>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">概要</label>
            <div class="layui-input-block">
                <input type="text" name="outline" class="layui-input" readonly>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">服务请求</label>
            <div class="layui-input-block">
                <input type="text" name="request" class="layui-input" readonly>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">创建人</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="founderName" readonly>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">创建时间</label>
                <div class="layui-input-inline">
                    <input type="text" name="creatorTime" class="layui-input" readonly>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">分配人</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="distriName" readonly>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">分配时间</label>
                <div class="layui-input-inline">
                    <input type="text" name="assignerTime" class="layui-input" readonly>
                </div>
            </div>
        </div>
    <%--</form>--%>
    <%--<form class="layui-form" id="handleForm" lay-filter="handleForm">--%>
        <div class="layui-form-item">
            <label class="layui-form-label">服务处理</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入处理"  class="layui-textarea" name="handle" id="chuli" ></textarea>
                <%--<input type="text" id="handles">--%>
                    <%--<input type="text" name="clientele" autocomplete="off" id="chuli" class="layui-input" >--%>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">处理人</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="handleName"  readonly>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">处理时间</label>
                <div class="layui-input-inline">
                    <input type="text" name="handleTime" class="layui-input" id="handleTime" readonly>
                </div>
            </div>
        </div>
    </form>
</div>
<div class="box-pad">
    <h1>服务归档</h1>
    <hr>
    <form class="layui-form">
        <%--<input type="text"  value="${sessionScope.login_user.id}">--%>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">客户名：</label>
                <div class="layui-inline">
                    <input type="text" id="clientele" class="layui-input" autocomplete="off">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">服务类型：</label>
                <div class="layui-inline">
                    <select id="serviceType" name="typeid" class="layui-select">
                        <option value="-1">请选择</option>
                        <c:forEach items="${crmDictionaries}" var="cd">
                            <option value="${cd.id}">${cd.name}</option>
                        </c:forEach>
                    </select>
                </div>
            </div>
            <button type="button" class="layui-btn" style="margin-bottom: 10px" onclick="searchData()">查询</button>
        </div>
    </form>
    <table class="layui-table" lay-data="{url:'/Service/chulineirong',page:true, id:'userTable',toolbar:'#toolbarDemo',defaultToolbar: ['filter', 'print', 'exports'],even: true}" lay-filter="userTable">
        <thead>
        <tr>
            <th lay-data="{field:'id', width:80, sort: true}">ID</th>
            <th lay-data="{field:'clientele', width:180}">用户名</th>
            <th lay-data="{templet:'#typeid'}">服务类型</th>
            <th lay-data="{field:'outline'}">概要</th>
            <th lay-data="{templet:'#user'}">创建人</th>
            <th lay-data="{field:'assignerTime'}">创建时间</th>
            <th lay-data="{toolbar:'#barDemo'}">操作</th>
        </tr>
        </thead>
    </table>

    <script>
        // document.getElementById("serviceForm").reset();        //清空form表单内容
        function searchData(){
            layui.table.reload("userTable",{
                page:{
                    curr : 1
                },
                where:{
                    "clientele":$("#clientele").val(),
                    "typeid" : $("#serviceType").val()
                }
            });
        }


        //  layui渲染
        var table;
        layui.use(['table','form'], function () {
            table = layui.table;
            var form = layui.form;
            table.on('tool(userTable)',function (obj) {
                var e = obj.event;
                var data=obj.data
                $("#detailType").val(data.dictionariesid.name);
                $("#distriName").val(data.fenpei.username)
                $("#chuliid").val(data.id)
                switch (e){
                    case "select":
                        $("#founderName").val(data.crmUser.username);
                        $("#handleName").val(data.fenpei.username)
                        layer.open({
                            type: 1,
                            title: "处理服务",
                            skin: "layui-layer-molv",
                            anim: 0,
                            offset:"260px;",
                            area: "800px",
                            content: $("#handle"),
                            btn: ['确定','取消'],
                            success:function(){
                                <%--$.get("${path}/Service/chulineirong",{"id":data.id},function (date) {--%>
                                    layui.form.val("serviceForm",data);
                                // })
                            },
                            yes : function (index) {
                                var chulis=$("#chuli").val();
                                if(chulis==null || chulis==""){
                                    layer.msg("仔细填写...",{icon:5,time:1200,anim:6},function () {});
                                    return false;
                                }
                                $("#handles").val(chulis);
                                var str = $("#serviceForm").serialize();
                                console.log(str)
                                $.post("${path}/Service/chuliservice",str,function (){
                                    layer.msg("提交成功...",{time:1200})
                                    layer.close(index);
                                    table.reload('userTable');
                                });
                            }
                        })
                        break;
                }
            })
            //  获取时间
            function getNow(s) {
                return s < 10 ? '0' + s : s;
            }

            function dates() {
                var now = new Date();
                //格式化日，如果小于9，前面补0
                var day = ("0" + now.getDate()).slice(-2);
                //格式化月，如果小于9，前面补0
                var month = ("0" + (now.getMonth() + 1)).slice(-2);
                var h = now.getHours();
                var minute = now.getMinutes();
                var s = now.getSeconds();
                //拼装完整日期格式
                var today = now.getFullYear() + "-" + (month) + "-" + (day) + " " + getNow(h) + ":" + getNow(minute) + ":" + getNow(s);
                return today;
            }
            $("#handleTime").val(dates());
        })
    </script>
    <script type="text/html" id="typeid">
        {{d.dictionariesid.name}}
    </script>
    <script type="text/html" id="user">
        {{d.crmUser.username}}
    </script>
    <!--  分配、删除  -->
    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-xs " lay-event="select" title="处理"><span class="layui-icon layui-icon-edit"></span></a>
    </script>
</div>
</body>
</html>
